// index.js
// 获取应用实例
const app = getApp()
Page({
    data: {
        username: "",
        password: "",
        inputstatu: true
    },
    pwdinput(e) {
        this.setData({
            password: e.detail,
        });
        if (this.data.username != "" && this.data.password != "") {
            this.setData({
                inputstatu: false
            })
        } else {
            this.setData({
                inputstatu: true
            })
        }
    },
    userinput(e) {
        this.setData({
            username: e.detail,
        });
        if (this.data.username != "" && this.data.password != "") {
            this.setData({
                inputstatu: false
            })
        } else {
            this.setData({
                inputstatu: true
            })
        }
    },
    //自定义函数
    //登录
    onLogin() {
        wx.request({
            url: 'http://localhost:8080/user/login/' + this.data.username + '/' + this.data.password,
            method: 'GET',
            success: (res => {
                console.log(res.data);
                if (res.data.code == 1) {
                    wx.switchTab({
                        url: '../user/user',
                    })
                } else {
                   wx.showToast({
                     title: res.data.msg,
                     icon:"none"
                   })
                }
            })
        })
    }
})